email me at borlaj@portlandschools.org
notes previous (09/07/06) submit the dump links  
 

Hints:

//To find square root of 16
Math.sqrt(16);
//To find square of 4
Math.pow(4,2)
//To go through a word getting each letter
for (int i=0;i<word.length();i++)
	System.out.println(word.charAt(i));

 

 

HWJ8_MethodPractice - all do 6, advanced more (2-4 more)

Assignment: (in each method when I say take in; that means as a parameter - DO NOT USE THE SCANNER class)

 

 

  1. toGrams that will take two doubles in pounds and ounces and return the number of grams
  2. Create a method findLonger that will take in two words and return the one that is longer. If they are both the same return "you fool"
  3. Create a method findConnections that takes in n number of computers and returns how many connections you need.
  4. daysInMonth that will take in an int (1-12) for the number of the month and return how many days it has in the month (non leap year)
  5. Create a method called convertToMiles that takes in kilometers as a double and returns the miles as a double
  6. Create a method called findDiagonal that will take in the width and height of television and it will return the diagonal. So 15,20, would return 25.
  7. Create a method called isLeapYear that will take in a year, and return true if it is a leap year, false otherwise. (The rules for leapYear are not as obvious as you thought. See here
  8. daysInMonth that will take in 2 ints (one for for the number of the month and one for the year) it will return an int and return how many days it has in that month.(for simplicity lets say every year divisible by 4 is a leap year)
  9. isEven that will take in an int as a parameter and will return true or false depending if its even.
    • to do this you will need to know about the % operator. You already know +-*/. % (Remainder or Mod) operator finds the remainder. So:
      • 16%3 would be 1 (if 16 is divided by 3 the remainder is 1)
      • 24%5 would be 4
      • 435%100 would be 35
      • 4%6 would be 4
  10. nextMultiple of 10 that will take in an int as a parameter and will return the next multiple of 10. (again use % remainder operator)
  11. Create a method called makeWheelOfForturne that will take in a String and replace all the vowels with '_'. It will then return that new word.
  12. daysInMonth that will take in 2 ints (one for for the number of the month and one for the year) it will return an int and return how many days it has in that month.(either use isLeapYear or for simplicity lets say every year divisible by 4 is a leap year)